home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / Xsun / patches / sunBW2.c.patch < prev    next >
Encoding:
Text File  |  1991-11-05  |  4.1 KB  |  172 lines

  1. *** /tmp/,RCSt1463155    Mon Nov  4 17:41:10 1991
  2. --- sunBW2.c    Tue Jul 24 18:01:12 1990
  3. ***************
  4. *** 55,65 ****
  5.   
  6.   #include    "sun.h"
  7.   #include    "resource.h"
  8.   
  9.   #include    <sys/mman.h>
  10.   #include    <sundev/bw2reg.h>
  11.   
  12. - extern caddr_t mmap();
  13.   
  14.   typedef struct bw2 {
  15.       u_char    image[BW2_FBSIZE];          /* Pixel buffer */
  16. --- 55,71 ----
  17.   
  18.   #include    "sun.h"
  19.   #include    "resource.h"
  20. + #include "sys/fb.h"
  21. + #include "sys/ioctl.h"
  22. + #include "kernel/vmMach.h"
  23. + #include "sys/types.h"
  24.   
  25. + extern caddr_t mmap();
  26.   #include    <sys/mman.h>
  27. + #ifndef    sprite
  28.   #include    <sundev/bw2reg.h>
  29.   
  30.   
  31.   typedef struct bw2 {
  32.       u_char    image[BW2_FBSIZE];          /* Pixel buffer */
  33. ***************
  34. *** 68,73 ****
  35. --- 74,80 ----
  36.   typedef struct bw2hr {
  37.       u_char    image[BW2_FBSIZE_HIRES];          /* Pixel buffer */
  38.   } BW2HR, BW2HRRec, *BW2HRPtr;
  39. + #endif    sprite
  40.   
  41.   static int  sunBW2ScreenIndex;
  42.   
  43. ***************
  44. *** 195,204 ****
  45. --- 202,245 ----
  46.       int              argc;            /* The number of the Server's arguments. */
  47.       char          **argv;       /* The arguments themselves. Don't change! */
  48.   {
  49. + #ifdef    NOTDEF
  50. +     fbtype    fbt;
  51. +     fbaddr    fba;
  52. +     pointer    buffer;
  53. +     if(Fb_GTYPE(&fbt) != SUCCESS) {
  54. +         return FALSE;
  55. +     }
  56. +     switch(fbt.fb_type) {
  57. +     case FBTYPE_SUN2BW:
  58. +         if(Fb_MAP(&fba) != SUCCESS) {
  59. +             return FALSE;
  60. +         }
  61. +         buffer = fba.fb_buffer;
  62. +         break;
  63. +     case FBTYPE_SUN4COLOR:
  64. +         if(Fb_MAP(&fba) != SUCCESS) {
  65. +             return FALSE;
  66. +         }
  67. +         buffer = fba.fb_overlay;
  68. +         /* fudge */
  69. +         fbt.fb_type = FBTYPE_SUN2BW;
  70. +         fbt.fb_depth = 1;
  71. +         fbt.fb_cmsize = 2;
  72. +         fbt.fb_size = 128*1024;
  73. +         break;
  74. +     default:
  75. +         return FALSE;
  76. +     }
  77. + #endif NOTDEF
  78.       int         fd;
  79.       struct fbtype fbType;
  80.       int        pagemask, mapsize;
  81.       caddr_t    addr, mapaddr;
  82. + #ifdef sprite
  83. +     int        sizeToUse;
  84. + #endif /* sprite */
  85.   
  86.       if ((fd = sunOpenFrameBuffer(FBTYPE_SUN2BW, &fbType, index, fbNum,
  87.                    argc, argv)) < 0)
  88. ***************
  89. *** 219,225 ****
  90. --- 260,273 ----
  91.        * If we are running pre-SunOS 4.0 then we first need to
  92.        * allocate some address range for mmap() to replace.
  93.        */
  94. + #ifdef sprite
  95. +     sizeToUse = ((mapsize + VMMACH_SEG_SIZE) & ~(VMMACH_SEG_SIZE-1))
  96. +         + VMMACH_SEG_SIZE;
  97. +     addr = (caddr_t) malloc(sizeToUse);
  98. +     if (addr == NULL) {
  99. + #else
  100.       if ((addr = (caddr_t) valloc(mapsize)) == 0) {
  101. + #endif /* sprite */
  102.           ErrorF("Could not allocate room for frame buffer.\n");
  103.           (void) close(fd);
  104.           return FALSE;
  105. ***************
  106. *** 226,231 ****
  107. --- 274,284 ----
  108.       }
  109.   #endif _MAP_NEW
  110.   
  111. + #ifdef sprite
  112. +     addr = (caddr_t) mmap((caddr_t) addr, mapsize,
  113. +         PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0);
  114. +     if (addr == (caddr_t) NULL) {
  115. + #else
  116.       /*
  117.        * In SunOS 4.0 the standard C library mmap() system call
  118.        * wrapper will automatically add a _MAP_NEW flag for us.
  119. ***************
  120. *** 235,252 ****
  121.        */
  122.       if ((mapaddr = (caddr_t) mmap(addr, mapsize,
  123.           PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0)) == (caddr_t) -1) {
  124.           Error("mapping BW2");
  125.           (void) close(fd);
  126.           return FALSE;
  127.       }
  128.   
  129.       if (mapaddr == 0)
  130.           mapaddr = addr;
  131.   
  132. !     sunFbs[index].fb = (pointer)mapaddr;
  133. !     sunFbs[index].fd = fd;
  134.       sunFbs[index].info = fbType;
  135.       sunFbs[index].EnterLeave = NULL;
  136.       return TRUE;
  137.   }
  138.   
  139. --- 288,316 ----
  140.        */
  141.       if ((mapaddr = (caddr_t) mmap(addr, mapsize,
  142.           PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0)) == (caddr_t) -1) {
  143. + #endif /* sprite */
  144.           Error("mapping BW2");
  145.           (void) close(fd);
  146.           return FALSE;
  147.       }
  148.   
  149. + #ifndef sprite
  150.       if (mapaddr == 0)
  151.           mapaddr = addr;
  152. + #endif /* sprite */
  153.   
  154. ! #ifdef sprite
  155. !     sunFbs[index].fb = (pointer) addr;
  156. !     /*
  157. !      * XXX What do we do here about fudging the FBTYPE_SUN4COLOR to be
  158. !      * black and white (as in the notdef'ed section above).?
  159. !      */
  160. ! #else
  161. !     sunFbs[index].fb = buffer;
  162. ! #endif /* sprite */
  163.       sunFbs[index].info = fbType;
  164.       sunFbs[index].EnterLeave = NULL;
  165. +     sunFbs[index].fd = fd;
  166.       return TRUE;
  167.   }
  168.   
  169.